<?php

abstract class AbstractController
{
	protected $view;
	protected $requstMethod;
	
	public function __construct($moduleName, $actionName, $viewObj = null)
	{
		if(empty($moduleName) || empty($actionName))
		{
			exit('Error');
		}
		
		if($viewObj == null)
		{
    		$this->view = new View(null);
		}
		else
		{
			$this->view = $viewObj;
		}
		$this->view->moduleName = $moduleName;
    	$this->view->actionName = $actionName;
		
		if(method_exists($this, '_init'))
		{
			$this->_init();
		}
		
		$this->requstMethod = $_SERVER['REQUEST_METHOD'];
	}

	protected function _redirect($url, $time = 0)
	{
		header("Location: ".$url);
        exit();
	}
	
	public function __destruct()
	{
	    RegGlobal::set('ACTION_END_TIME', Functions::microtime_float());
	}
}